/*
let openID;
let user;
let roomList;
let room;
let locationList;
let state1Header;
let state2Header;
let state1Page;
let state2Page;
let state1Moudle;
let footer;
let pageState;

state1Header = '<div class="pos-fixed">\n' +
    '        <div class="fixed-set">\n' +
    '            会议室占用\n' +
    '        </div>\n' +
    '    </div>\n' +
    '    <div class="out-top">\n' +
    '    </div>';
state2Header = '<div class="pos-fixed">\n' +
    '        <ul class="nav nav-pills nav-fill">\n' +
    '            <li class="nav-width">\n' +
    '                <button type="button" class="btn-back" onclick="back()">返回</button>\n' +
    '            </li>\n' +
    '            <li class="nav-width">\n' +
    '                <div class="fixed-set">\n' +
    '                    会议室占用情况\n' +
    '                </div>\n' +
    '            </li>\n' +
    '        </ul>\n' +
    '    </div>\n' +
    '    <div class="out-top">\n' +
    '    </div>'
footer = '<div id="mynav" >\n' +
    '        <ul class="nav nav-pills nav-fill">\n' +
    '            <li class="nav-item nav-width">\n' +
    '                <button class="nav-link nav-height" onclick="universal_redirectToBooking()">预约会议室</button>\n' +
    '            </li>\n' +
    '            <li class="nav-item nav-width">\n' +
    '                <button class="nav-link  nav-height active">查看占用</button>\n' +
    '            </li>\n' +
    '            <li class="nav-item nav-width">\n' +
    '                <button class="nav-link nav-height " onclick="universal_redirectToManagement()">个人中心</button>\n' +
    '            </li>\n' +
    '        </ul>\n' +
    '    </div>'
state1Page = state1Header;
state2Page = state2Header;

function back(){
    pageState = 1;
    document.getElementById('fatherBox').innerHTML = state1Page;
}

function changeToState2(){

}

//正则表达式获取地址栏?后的指定name参数
function universal_getParameterString(name) {
    let result = null;
    let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
    let r = window.location.search.substr(1).match(reg);
    if (r != null) {
        result = unescape(r[2]);
    }
    return result;
}

function universal_redirectToManagement() {
    $.ajax({
        type: 'GET',
        //contentType:'',
        url: '/management/page?openid=' + openID,
        async:false,
        success: function (data) {
            console.log(data + 'send successfully');
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            //状态码
            console.log(XMLHttpRequest.status);
            // 状态
            console.log(XMLHttpRequest.readyState);
            // 错误信息
            console.log(textStatus);
        }
    });
}

function universal_redirectToBooking() {
    $.ajax({
        type: 'GET',
        //contentType:'',
        url: '/booking/page?openid=' + openID,
        async:false,
        success: function (data) {
            console.log(data + 'send successfully');
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            //状态码
            console.log(XMLHttpRequest.status);
            // 状态
            console.log(XMLHttpRequest.readyState);
            // 错误信息
            console.log(textStatus);
        }
    });
}

function setState1Moudle(number){
    room = {
        js_ID:roomList[number]['ID'],
        js_name:roomList[number]['name'],
        js_location:roomList[number]['location'],
        js_capacity:roomList[number]['capacity'],
        js_main_use:roomList[number]['main_use'],
        js_status:roomList[number]['status']
    };
    state1Moudle = '<div class="row detail-bottom " id="'+ room.js_ID +'">\n' +
        '                            <div class="right-cont1" id="roomName_'+ room.js_ID + '">\n' +
        '                                会议室101\n' +
        '                            </div>\n' +
        '                            <div class="right-cont2" id="roomMain_use_'+ room.js_ID +'">\n' +
        '                                <div>\n' +
        '                                    多媒体会议室\n' +
        '                                </div>\n' +
        '                                <div>\n' +
        '                                    <div class="right-display-inline">\n' +
        '                                        容纳人数:\n' +
        '                                    </div>\n' +
        '                                    <div class="right-display-inline" id="roomCapacity_'+ room.js_ID +'">\n' +
        '                                        200\n' +
        '                                    </div>\n' +
        '                                </div>\n' +
        '                            </div>\n' +
        '                            <div class="right-cont3">\n' +
        '                                <button type="button" class="btn-primary right-btn">预约</button>\n' +
        '                            </div>\n' +
        '                            <div class="right-cont4">\n' +
        '                                <button type="button" class="btn-primary right-btn" onclick="changeToState2()" name="'+ room.js_ID +'">查看</button>\n' +
        '                            </div>\n' +
        '                    </div>'
}

function getOpenRoomList(){
    $.ajax({
        url:'meetingRoom/getAllMeetingRoomByLocation',
        method:'GET',
        async:false,
        data:locationList[0]['location'],
        success:function(data){
            console.log(data);
            roomList = data;
            for(let i = 0;i<roomList.length;i++){
                setState1Moudle(i);
                state1Page = state1Page + state1Moudle;
            }
            state1Page = state1Page + footer;
        },
        error: function (err) {
            console.log(err)
        }
    });
}

function universal_init() {
    pageState = 1;
    openID = universal_getParameterString('openid');
    $.ajax({
        url: '/meetingRoom/greeting?openid=' + openID,
        method: 'GET',
        async: false,
        //contentType: 'application/json',
        success: function (data) {
            console.log(data);
            user = data;
        },
        error: function (err) {
            console.log(err)
        }
    });
    $.ajax({
        url:'meetingRoom/getAllLocation',
        method:'GET',
        async:false,
        success:function(data){
            console.log(data);
            locationList = data;
            getOpenRoomList();
        },
        error: function (err) {
            console.log(err)
        }
    });
}

window.onload = universal_init();

 */